<template>
    <div id="searchView">
        <table class="table">
            <tbody>
               <tr>
                    <td>  
                        <el-input placeholder="姓名" v-model="searchData.sname" prefix-icon="el-icon-search"
                        @focus="clearAnotherInput('sname')" clearable
                        >
                        </el-input>
                    </td>
                    <td>
                         <el-input  placeholder="联系电话"   v-model="searchData.mobile"     prefix-icon="el-icon-search" @focus="clearAnotherInput('mobile')" clearable>
                        </el-input>
                    </td>
                    <td>
                         <el-date-picker
                            v-model="searchData.arriveTime"
                            type="date"
                            placeholder="上门时间"
                            
                            value-format="yyyy-MM-dd"
                            suffix-icon="el-icon-date"
                            @focus="clearAnotherInput('arriveTime')"
                            >
                        </el-date-picker>
                    </td>
                    <td>
                         <el-input placeholder="咨询师" v-model="searchData.advisor"  @focus="clearAnotherInput('advisor')"   prefix-icon="el-icon-search" clearable>
                        </el-input>
                    </td>
                     <td>
                        <!-- <el-select v-model="searchData.status" placeholder="状态" @click.native="loadStatus">
                            <el-option v-for="item in social_status "
                            :key="item.kvalue"
                            :label="item.kvalue"
                            :value="item.kkey"
                            suffix-icon="el-icon-search"

                            ></el-option>
                        </el-select> -->
                    </td>
                    <td>
                        <el-button type="primary" @click="startSearch"  prefix-icon="el-icon-date">查询</el-button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>
<script>
export default {
    props: ['baseURL'],
    data(){
        return {
            dataSource:[],
            searchData: { //搜索数据
                sname: '',
                mobile: '',
                arriveTime: '',
                advisor: '',
                status: '',
            },
        }
    },
    methods: {
        clearAnotherInput(searchType){
            for(var key in this.searchData){
                if(key!=searchType){
                    this.searchData[key]=''
                }
            }
        },
        startSearch(){
            var promise = this.search(this.searchData,this.baseURL);
            promise.then((response)=>{
                this.$emit('searchResult',this.dataSource)
            })
        }
    }
}
</script>

